package com.xps.charmingshop.date.net;


import com.xps.charmingshop.date.servicrapi.UserApi;

import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

public abstract class RetrofitUtils {
    public static final String ROOT = "http://www.meitianpaotui.com/api";

    protected static UserApi userApi = null;
    protected static OkHttpClient okHttpClient = OkhttpUtils.getOkHttpClient();

    protected static UserApi getUserApi() {
        if (null == userApi) {
            Retrofit mRetrofit = new Retrofit.Builder()
                    .baseUrl(ROOT + "/")
                    .addConverterFactory(GsonConverterFactory.create())
                    .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                    .client(okHttpClient)
                    .build();
            userApi = mRetrofit.create(UserApi.class);
        }
        return userApi;
    }
}